package cn.wolfcode.rockitmq.consumer;

import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 消费者：
 *      1.消费者交给Spring管理
 *      2.类上贴 RocketMQMessageListener 消息中间件的监听注解
 *      3.类要实现 RocketMQListener 接口
 *      4.onMessage 方法：对消息的具体处理
 */

@Component
@RocketMQMessageListener(
        consumerGroup = "boot-consumer-demo",
        topic = "01-boot", //跟生产者设置的来修改，主题要一致
        //selectorExpression = "TagA || TagCC",  //设置表达式来匹配到对应的Tag标签

        selectorType = SelectorType.SQL92,
        selectorExpression = "age > 15"
)
public class Consumer implements RocketMQListener<String> {

    @Override
    public void onMessage(String msg) {
        System.out.println("消费信息：" + msg);
    }
}
